package com.yihuier.yihuier.Controller.Common;

import org.junit.Test;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;


@RestController
public class FileController {
    /**
     * 拼接url
     * */
    public static  String filePathDispose(String absoluteAddress){
            if (absoluteAddress == null){
                return "absoluteAddress is null";
            }
            String prefixUrl ="http://sylardaemon.tech/file/";
            String[]  routenames = absoluteAddress.split("/");
            return prefixUrl+routenames[routenames.length-2]+"/"+routenames[routenames.length-1];
    }

    /**
     * 获得文件后缀名
     * */
    public static String getFileUrlSuffix(String filePath){
        String[]  results = filePath.split("\\.");
        if (results.length != 0){
            return "."+results[results.length-1];
        }
        return filePath;
    }

}
